/*
 * AD.h
 *
 *  Created on: Jan 22, 2012
 *      Author: sxg8392
 */

#ifndef AD_H_
#define AD_H_



// Base address to the A/D and D/A converter
#define BASE_ADDRESS					(0x280)


//A2D deffinitions
// Base address to the least significant byte
// of the digital data
#define AD_LSB_BASE_ADDRESS				(BASE_ADDRESS)
// Base address to the most significant byte
// of the digital data
#define AD_MSB_BASE_ADDRESS				(BASE_ADDRESS + 0x01)
// What to write to the base address to start the
// A/D conversion
#define AD_BASE_OUTPUT_VAL					(0x80)
// The address to an A/D channel
#define AD_CHANNEL_ADDRESS				(BASE_ADDRESS + 0x02)
// Writing to the A/D channel to specify the channel
#define AD_CHANNEL_VAL					(0x44)
// The address to the analog input status address
#define ANALOG_INPUT_STATUS_ADDRESS		(BASE_ADDRESS + 0x03)
// Writing to the analog input status address to
// specify the range of the input voltage
#define ANALOG_INPUT_STATUS_VAL			(0x00)
// The bit to wait on for the conversion to finish
#define ANALOG_INPUT_WAIT_BIT			(0b00100000)





void initADRegister(void);
float readValue();

#define AD_WAIT 10
#endif /* AD_H_ */
